package cn.xunyijia.ctrl;

import cn.xunyijia.po.User;
import cn.xunyijia.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class IndexCtrl {
    private final IUserService userService;

    @Autowired
    public IndexCtrl(IUserService userService) {
        this.userService = userService;
    }


    @RequestMapping("/index")
    public ModelAndView index() {
        ModelAndView mav = new ModelAndView("index");
        User user = userService.findUserById(1);
        mav.addObject("user", user);
        return mav;
    }
}
